//
//  HelpView.m
//  Scanner
//
//  Created by TGBUS on 12-8-1.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "HelpView.h"
#import "AppDelegate.h"

@implementation HelpView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setFrame:CGRectMake(0, 0, 320, 480)];
        [self setAlpha:0.0];
        
        [self setUserInteractionEnabled:YES];
        
        UIImageView *helpView=[[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 280, 440)];
        [helpView setImage:[UIImage imageNamed:@"Help.png"]];
        [self addSubview:helpView];
        [helpView release];
        
        UIButton *btnClose=[UIButton buttonWithType:UIButtonTypeCustom];
        [btnClose setFrame:CGRectMake(285, 5, 31, 31)];
        [btnClose setBackgroundImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateNormal];
        [btnClose addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btnClose];
        
        AppDelegate *appDelegate=[[UIApplication sharedApplication]delegate];
        [appDelegate.window addSubview:self];
    }
    return self;
}

-(void)close
{
    [UIView beginAnimations:nil context:nil];
    [self setAlpha:0.0];
    [UIView commitAnimations];
    [self performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.3];
}

-(void)show
{
    [UIView beginAnimations:nil context:nil];
    [self setAlpha:1.0];
    [UIView commitAnimations];
}

@end
